/**
 * 2016，thor.com，all rights reserved。
 * 
 * Project：		palmmall-core
 * Filename：	SComplaintConverter.java
 * Created：		2016年8月21日
 * Creator：		wolv
 */
package com.thor.palmmall.rest.complaint.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.palmmall.rest.complaint.AWorkRecord;
import com.thor.palmmall.spi.complaint.SComplaintLevel;
import com.thor.palmmall.spi.complaint.SWorkRecord;

/**
 * @author wolv
 *
 */
public class SWorkRecordConverter implements Converter<AWorkRecord, SWorkRecord> {

	public static SWorkRecordConverter getInstance() {
		if (instance == null)
			instance = new SWorkRecordConverter();
		return instance;
	}

	private static SWorkRecordConverter instance;

	private SWorkRecordConverter() {
	}

	@Override
	public SWorkRecord convert(AWorkRecord source) {
		if (source == null)
			return null;

		SWorkRecord target = new SWorkRecord();
		target.setBillNumber(source.getBillNumber());
		target.setComplaintGrade(SComplaintLevel.valueOf(source.getComplaintLevel().name()));
		target.setProcessInfo(source.getProcessInfo());
		target.setProcessLimitedTime(source.getProcessLimitedTime());
		target.setProcessPerson(UCN.newInstance(source.getProcessPerson()));
		target.setUuid(source.getUuid());
		target.setVersion(source.getVersion());

		return target;
	}
}
